package com.learn.thread;

/**
 * 测试Thread中常用方法
 */
class HelloThread extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if(i % 2 == 0){
                System.out.println(Thread.currentThread().getName() + ":" +
                        Thread.currentThread().getPriority() + ":" + i);
            }
            if(i == 30){
                try {
                    sleep(1000);
                } catch (InterruptedException e) {

                    e.printStackTrace();
                }
            }
        }
    }
}

public class ThreadMethod {
    public static void main(String[] args) throws InterruptedException {
        HelloThread t = new HelloThread();
        t.setName("subThread");
        t.setPriority(Thread.MIN_PRIORITY);
        t.start();

        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

        for (int i = 0; i < 100; i++) {
            if(i % 2 != 0){
                System.out.println(Thread.currentThread().getName() + ":"
                        + Thread.currentThread().getPriority() + ":" + i);
            }
        }
    }
}
